/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.compomics.spectrawl.view;

import com.compomics.spectrawl.config.PropertiesConfigurationHolder;
import com.compomics.spectrawl.controller.SpectrawlController;
import com.compomics.spectrawl.model.Experiment.ExperimentType;
import com.compomics.spectrawl.util.GuiUtils;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.util.concurrent.ExecutionException;
import javax.swing.*;
import org.apache.log4j.Logger;

/**
 *
 * @author niels
 */
public class ExperimentLoaderPanel extends javax.swing.JPanel {
    
    JFileChooser fileChooser;
    
    /**
     * Creates new form ExperimentLoaderPanel
     */
    public ExperimentLoaderPanel() {
        initComponents();
        fileChooser = new JFileChooser();
    }

    public JTextField getBinCeilingTextField() {
        return binCeilingTextField;
    }

    public JTextField getBinFloorTextField() {
        return binFloorTextField;
    }

    public JTextField getBinSizeTextField() {
        return binSizeTextField;
    }

    public JComboBox getExperimentTypeComboBox() {
        return experimentTypeComboBox;
    }

    public JButton getFileChooseButton() {
        return fileChooseButton;
    }

    public JButton getLoadExperimentButton() {
        return loadExperimentButton;
    }

    public JList getMgfFilesList() {
        return mgfFilesList;
    }

    public JTextField getMsLimsExperimentIdTextField() {
        return msLimsExperimentIdTextField;
    }

    public JProgressBar getSpectrawlProgressBar() {
        return spectrawlProgressBar;
    }

    public JLabel getSpectrawlProgressBarLabel() {
        return spectrawlProgressBarLabel;
    }
        
    public JPanel getExperimentSelectionPanel() {
        return experimentSelectionPanel;
    }

    public JPanel getMgfPanel() {
        return mgfPanel;
    }

    public JPanel getMsLimsPanel() {
        return msLimsPanel;
    }

    public JFileChooser getFileChooser() {
        return fileChooser;
    }
        
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {
        java.awt.GridBagConstraints gridBagConstraints;

        experimentSelectionPanel = new javax.swing.JPanel();
        experimentTypeLabel = new javax.swing.JLabel();
        experimentTypeComboBox = new javax.swing.JComboBox();
        msLimsPanel = new javax.swing.JPanel();
        experimentIdLabel = new javax.swing.JLabel();
        msLimsExperimentIdTextField = new javax.swing.JTextField();
        mgfPanel = new javax.swing.JPanel();
        mgfFileLabel = new javax.swing.JLabel();
        mgfFilesListScrollPane = new javax.swing.JScrollPane();
        mgfFilesList = new javax.swing.JList();
        fileChooseButton = new javax.swing.JButton();
        binConfigurationPanel = new javax.swing.JPanel();
        binFloorLabel = new javax.swing.JLabel();
        binFloorTextField = new javax.swing.JTextField();
        binCeilingLabel = new javax.swing.JLabel();
        binCeilingTextField = new javax.swing.JTextField();
        binSizeLabel = new javax.swing.JLabel();
        binSizeTextField = new javax.swing.JTextField();
        experimentButtonPanel = new javax.swing.JPanel();
        loadExperimentButton = new javax.swing.JButton();
        progressBarPanel = new javax.swing.JPanel();
        spectrawlProgressBarLabel = new javax.swing.JLabel();
        spectrawlProgressBar = new javax.swing.JProgressBar();

        setMinimumSize(new java.awt.Dimension(4, 4));
        setPreferredSize(new java.awt.Dimension(20, 20));
        setLayout(new java.awt.GridBagLayout());

        experimentSelectionPanel.setPreferredSize(new java.awt.Dimension(20, 20));
        experimentSelectionPanel.setLayout(new java.awt.GridBagLayout());

        experimentTypeLabel.setText("experiment type");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        experimentSelectionPanel.add(experimentTypeLabel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        experimentSelectionPanel.add(experimentTypeComboBox, gridBagConstraints);

        msLimsPanel.setLayout(new java.awt.GridBagLayout());

        experimentIdLabel.setText("MSLims experiment ID");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        msLimsPanel.add(experimentIdLabel, gridBagConstraints);

        msLimsExperimentIdTextField.setPreferredSize(new java.awt.Dimension(100, 25));
        msLimsPanel.add(msLimsExperimentIdTextField, new java.awt.GridBagConstraints());

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        experimentSelectionPanel.add(msLimsPanel, gridBagConstraints);

        mgfPanel.setLayout(new java.awt.GridBagLayout());

        mgfFileLabel.setText("MGF file(s)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        mgfPanel.add(mgfFileLabel, gridBagConstraints);

        mgfFilesListScrollPane.setPreferredSize(new java.awt.Dimension(300, 60));

        mgfFilesList.setEnabled(false);
        mgfFilesListScrollPane.setViewportView(mgfFilesList);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.VERTICAL;
        gridBagConstraints.weighty = 1.0;
        mgfPanel.add(mgfFilesListScrollPane, gridBagConstraints);

        fileChooseButton.setText("choose file(s)");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        mgfPanel.add(fileChooseButton, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        experimentSelectionPanel.add(mgfPanel, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 0.4;
        add(experimentSelectionPanel, gridBagConstraints);

        binConfigurationPanel.setPreferredSize(new java.awt.Dimension(20, 20));
        binConfigurationPanel.setRequestFocusEnabled(false);
        java.awt.GridBagLayout binConfigurationPanelLayout = new java.awt.GridBagLayout();
        binConfigurationPanelLayout.columnWidths = new int[] {0, 5, 0};
        binConfigurationPanelLayout.rowHeights = new int[] {0, 10, 0, 10, 0};
        binConfigurationPanel.setLayout(binConfigurationPanelLayout);

        binFloorLabel.setText("bin floor");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        binConfigurationPanel.add(binFloorLabel, gridBagConstraints);

        binFloorTextField.setMinimumSize(new java.awt.Dimension(6, 25));
        binFloorTextField.setPreferredSize(new java.awt.Dimension(60, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        binConfigurationPanel.add(binFloorTextField, gridBagConstraints);

        binCeilingLabel.setText("bin ceiling");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        binConfigurationPanel.add(binCeilingLabel, gridBagConstraints);

        binCeilingTextField.setMinimumSize(new java.awt.Dimension(6, 25));
        binCeilingTextField.setPreferredSize(new java.awt.Dimension(60, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        binConfigurationPanel.add(binCeilingTextField, gridBagConstraints);

        binSizeLabel.setText("bin size");
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        binConfigurationPanel.add(binSizeLabel, gridBagConstraints);

        binSizeTextField.setMinimumSize(new java.awt.Dimension(6, 25));
        binSizeTextField.setPreferredSize(new java.awt.Dimension(60, 25));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 2;
        gridBagConstraints.gridy = 4;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.WEST;
        gridBagConstraints.weightx = 1.0;
        binConfigurationPanel.add(binSizeTextField, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.FIRST_LINE_START;
        gridBagConstraints.weightx = 0.25;
        gridBagConstraints.weighty = 0.5;
        add(binConfigurationPanel, gridBagConstraints);

        experimentButtonPanel.setPreferredSize(new java.awt.Dimension(20, 20));
        experimentButtonPanel.setLayout(new java.awt.GridBagLayout());

        loadExperimentButton.setText("load");
        loadExperimentButton.setPreferredSize(new java.awt.Dimension(97, 23));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 0;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.LAST_LINE_END;
        gridBagConstraints.weightx = 1.0;
        gridBagConstraints.weighty = 1.0;
        experimentButtonPanel.add(loadExperimentButton, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 1;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.EAST;
        gridBagConstraints.weightx = 0.75;
        gridBagConstraints.weighty = 0.5;
        add(experimentButtonPanel, gridBagConstraints);

        progressBarPanel.setPreferredSize(new java.awt.Dimension(20, 40));
        progressBarPanel.setLayout(new java.awt.GridBagLayout());

        spectrawlProgressBarLabel.setPreferredSize(new java.awt.Dimension(0, 20));
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        progressBarPanel.add(spectrawlProgressBarLabel, gridBagConstraints);

        spectrawlProgressBar.setPreferredSize(new java.awt.Dimension(146, 20));
        spectrawlProgressBar.setRequestFocusEnabled(false);
        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 1;
        gridBagConstraints.fill = java.awt.GridBagConstraints.BOTH;
        gridBagConstraints.weightx = 1.0;
        progressBarPanel.add(spectrawlProgressBar, gridBagConstraints);

        gridBagConstraints = new java.awt.GridBagConstraints();
        gridBagConstraints.gridx = 0;
        gridBagConstraints.gridy = 2;
        gridBagConstraints.gridwidth = 2;
        gridBagConstraints.fill = java.awt.GridBagConstraints.HORIZONTAL;
        gridBagConstraints.anchor = java.awt.GridBagConstraints.BASELINE;
        gridBagConstraints.weightx = 1.0;
        add(progressBarPanel, gridBagConstraints);
    }// </editor-fold>//GEN-END:initComponents
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel binCeilingLabel;
    private javax.swing.JTextField binCeilingTextField;
    private javax.swing.JPanel binConfigurationPanel;
    private javax.swing.JLabel binFloorLabel;
    private javax.swing.JTextField binFloorTextField;
    private javax.swing.JLabel binSizeLabel;
    private javax.swing.JTextField binSizeTextField;
    private javax.swing.JPanel experimentButtonPanel;
    private javax.swing.JLabel experimentIdLabel;
    private javax.swing.JPanel experimentSelectionPanel;
    private javax.swing.JComboBox experimentTypeComboBox;
    private javax.swing.JLabel experimentTypeLabel;
    private javax.swing.JButton fileChooseButton;
    private javax.swing.JButton loadExperimentButton;
    private javax.swing.JLabel mgfFileLabel;
    private javax.swing.JList mgfFilesList;
    private javax.swing.JScrollPane mgfFilesListScrollPane;
    private javax.swing.JPanel mgfPanel;
    private javax.swing.JTextField msLimsExperimentIdTextField;
    private javax.swing.JPanel msLimsPanel;
    private javax.swing.JPanel progressBarPanel;
    private javax.swing.JProgressBar spectrawlProgressBar;
    private javax.swing.JLabel spectrawlProgressBarLabel;
    // End of variables declaration//GEN-END:variables
}
